package app.softtech.freechat.database;

import android.content.ContentValues;
import android.database.Cursor;

public class DatabaseChat {

	private int id;
	private String mMessage;
	private int mIsSend;
	private int mFriendId;
	private int mUserId;
	private int mGroupId;
	private String mDateChat;

	public DatabaseChat(int id, String mMessage, int mIsSend, int mFriendId,
			int mUserId, int mGroupId, String mDateChat) {
		super();
		this.id = id;
		this.mMessage = mMessage;
		this.mIsSend = mIsSend;
		this.mFriendId = mFriendId;
		this.mUserId = mUserId;
		this.mGroupId = mGroupId;
		this.mDateChat = mDateChat;
	}

	public DatabaseChat(String mMessage, int mIsSend, int mFriendId,
			int mUserId, int mGroupId) {
		super();
		this.mMessage = mMessage;
		this.mIsSend = mIsSend;
		this.mFriendId = mFriendId;
		this.mUserId = mUserId;
		this.mGroupId = mGroupId;
	}

	public DatabaseChat() {
		super();
		// TODO Auto-generated constructor stub
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMessage() {
		return mMessage;
	}

	public void setMessage(String mMessage) {
		this.mMessage = mMessage;
	}

	public int getIsSend() {
		return mIsSend;
	}

	public void setIsSend(int mIsSend) {
		this.mIsSend = mIsSend;
	}

	public int getFriendId() {
		return mFriendId;
	}

	public void setFriendId(int mFriendId) {
		this.mFriendId = mFriendId;
	}

	public int getUserId() {
		return mUserId;
	}

	public void setUserId(int mUserId) {
		this.mUserId = mUserId;
	}

	public int getGroupId() {
		return mGroupId;
	}

	public void setGroupId(int mGroupId) {
		this.mGroupId = mGroupId;
	}

	public String getDateChat() {
		return mDateChat;
	}

	public void setDateChat(String dateChat) {
		this.mDateChat = dateChat;
	}
	/**
	 * Get Values of DatabaseChat except ID
	 * @return ContentValues
	 */
	public ContentValues getValuesChat(){
		ContentValues values = new ContentValues();

		values.put(ConstantsDB.MESSAGE, this.getMessage());
		values.put(ConstantsDB.ISSEND, this.getIsSend());
		values.put(ConstantsDB.USER_ID, this.getUserId());
		values.put(ConstantsDB.FRIEND_ID, this.getFriendId());
		values.put(ConstantsDB.GROUP_ID, this.getGroupId());
		values.put(ConstantsDB.DATECHAT, this.getDateChat().toString());
		return values;
	}
	
	public static DatabaseChat setValuesFromCursor(Cursor cursor){

		DatabaseChat dc = new DatabaseChat();
		dc.id = cursor.getInt(cursor.getColumnIndex(ConstantsDB.ID));
		dc.mIsSend = cursor.getInt(cursor.getColumnIndex(ConstantsDB.ISSEND));
		dc.mMessage = cursor.getString(cursor.getColumnIndex(ConstantsDB.MESSAGE));
		dc.mFriendId = cursor.getInt(cursor.getColumnIndex(ConstantsDB.FRIEND_ID));
		dc.mUserId = cursor.getInt(cursor.getColumnIndex(ConstantsDB.USER_ID));
		dc.mGroupId = cursor.getInt(cursor.getColumnIndex(ConstantsDB.GROUP_ID));
		dc.mDateChat = cursor.getString(cursor.getColumnIndex(ConstantsDB.DATECHAT));
		
		return dc;
	}
}
